package main;

import java.awt.Rectangle;
import java.util.Vector;


import engine.AlternateStateThreadPoolExecutor;
import tools.Debug;
import tools.Fragment;
import tools.FragmentDirectory;

import tools.MMMEDirectory;
import util.ConsoleFrame;
import visualisation.MainFrame;
import XML.FragmentXML;
import XML.XMLParser;


public class Main {
	
	
	public final static boolean lowPerf = false;
	
	public final static String finalElement ="Application";	//final element, determine that a process is complete

	
	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args)  {
		
		/**/
//		Debug.debug();
//		ConsoleFrame stdout = new ConsoleFrame("ma console", new Rectangle(0,0,600,600), true, false); 
//		stdout.activate(true);
		
		new AlternateStateThreadPoolExecutor();
		AlternateStateThreadPoolExecutor.processExe.pause();
		
		
		//Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ProcessTest.xml");
		Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ADELFE.xml");		
		
		
		FragmentDirectory fragDir = new FragmentDirectory();
		MMMEDirectory elemDir =  new MMMEDirectory();
						
		Vector<Fragment> fragList=new Vector<Fragment>();
		
		for(FragmentXML f : vectorFragments){
			FragmentFactory.create(f.getName(),f.getOutput(),f.getInput(),f.getPreference(),fragDir,elemDir);
					
		}
		
		//System.out.println("new frame");
		new MainFrame(fragDir.getFragmentList());
		
		(new Thread(new ProcessFinder(fragDir, elemDir))).start();
		
//		for(FragmentAgent f : fragList)
//			f.start();
		
		//new SimulatedUser(elemDir).start();

	}
	


}
